﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<TireBias.Models.BIASPLANModel.BIASPLAN_DS>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Header_line
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% var Act = Model.First(); %>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(Act._Text))
         {%>
<div class="cell shadow"  style="font-size:x-large; padding:5px; background-color:#C38DEC; color:White"><%= Act._Text%></div>
<%} %>
<table width="100%">

<tr>
<td>
   <div class="float-left" >
      <div>
   
         <button type="button" id="bt" class="shadow fontBig" style="height: 300px; width: 475px;">
            <div id="seq" style="color:#999">
            <%= Act._Plandt %>-<%=Act._Itemno %>
            </div>
            <div id="topped">
            <%= Act._Topcrdcd %>
            </div>
            <div id="sizes">
            <%=Act._Size %>
            </div>
            <div id="forming">
            <%=Act._Forming %>
            </div>
        <% if (WinNemoLib.StrUtil.IsNotEmpty(Act._P1))
         { %><div>P1</div>
        <%} %>
             <% if (WinNemoLib.StrUtil.IsNotEmpty(Act._P2))
         { %><div>P2</div>
        <%} %>
             <% if (WinNemoLib.StrUtil.IsNotEmpty(Act._P3))
         { %><div>P3</div>
        <%} %>
             <% if (WinNemoLib.StrUtil.IsNotEmpty(Act._P4))
         { %><div>P4</div>
        <%} %>
         </button>
      </div>
      <br />
      <div class="float-left" style="padding-left:25px;">
         <div  class="float-left" style="width: 200px; height:60px; padding-right:10px;">
            <h5>UPDATE PLAN :</h5><span class="fontTh">แผนปรับปรุงโดย</span>
         </div>        
         <div id="pln" >
         <span> <%=Act._UpTemp %><br /><%= Act._Uptdat %></span>
         </div>
      </div>
   </div>
   <div class="float-left" style="float:left; ">
      <table class=" shadow fontTB "id="dataTbl" width="95%">
         <thead>
            <tr class="head">
               <td class="cell" style="width: 15%; " rowspan="2">
                  SEQ<br /><span class="fontTh">ลำดับ</span>
               </td>
               <td class="cell" style="width: 15%" rowspan="2">
                  TOPPED CORD<br /><span class="fontTh">ผ้าใบ</span>
               </td>
               <td class="cell" style="width: 20%" rowspan="2">
                  SIZE<br /><span class="fontTh">ขนาดผ้าใบ</span>
               </td>
               <td class="cell" colspan="4" align="center" style="border-bottom:1px solid #000000">
               <span class="fontTh">  ความยาวผ้าใบ</span> <span class="fontTh">(มม.)</span></td>
               <td class="cell" style="width: 15%; " rowspan="2">
                  FORMING<br /><span class="fontTh">ขนาดผ้าใบ</span>
               </td>
            </tr>
            <tr class="head">
               <td class="cell" style="width: 10%;">
                  P1<br /><span class="fontTh">ชั้นที่ 1 </span>&nbsp;</td>
                 <td class="cell" style="width: 10%;">
                  P2<br /><span class="fontTh">ชั้นที่ 2 </span>&nbsp;</td>
                 <td class="cell" style="width: 10%;">
                  P3<br /><span class="fontTh">ชั้นที่ 3</span>
               </td>
                 <td class="cell" style="width: 10%;">
                  P4<br /><span class="fontTh">ชั้นที่ 4 </span>
               </td>
            </tr>
         </thead>
         <tbody>
            <%
               int i = 0;

               foreach (var item in Model)
               {
                  i = i + 1;
                  string upd = "";
                  string trrow = "rowa";
                  if (i % 2 == 0) trrow = "rowb";
                  string seq = item._Plandt + '-' + item._Itemno;
                  if (i == 1) {
                     trrow = trrow + " actived";
                     upd= item._UpTemp+ " : "+ item._Uptdat;
                  };
            %>
            <tr class='<%= trrow %>' style="height: 35px;">
               <td class="cell" style="text-align: center;">
                  <%= seq %>
               </td>
               <td class="cell" style="text-align: center;">
                  <%: Html.DisplayFor(modelItem => item._Topcrdcd) %>
               </td>
               <td class="cell" style="text-align: center;">
                  <%: Html.DisplayFor(modelItem => item._Size) %>
               </td>
               <td class="cell" style="text-align: center;">
                  <%: Html.DisplayFor(modelItem => item._P1) %>
               </td>
                <td class="cell" style="text-align: center;">
                  <%: Html.DisplayFor(modelItem => item._P2) %>
               </td>
                <td class="cell" style="text-align: center;">
                  <%: Html.DisplayFor(modelItem => item._P3) %>
               </td>
                <td class="cell" style="text-align: center;">
                  <%: Html.DisplayFor(modelItem => item._P4) %>
               </td>
                <td class="cell" style="text-align: center;">
                  <%: Html.DisplayFor(modelItem => item._Forming) %>
               </td>
              
            </tr>
            <% } %>
         </tbody>
      </table>
   </div>
   
   </td></tr>
   </table>
   

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="FeaturedContent" runat="server">
    <section class="featured">
 <div class="content-wrapper" style="height:40px">
            <hgroup class="title float-left">
            <h1>Bias Head Computer</h1>
                <h2  style="padding-left:55px;">BIAS NO.<%: TireBias.Models.SessionBag.Current.biasno %></h2>                     
            </hgroup> 
             <hgroup class="title float-right">
                <h3>
         Name :
         <% if (Request.IsAuthenticated)
         { %>
         <%:  User.Identity.Name %>
         <% } %></h3>
            </hgroup>   
 </div>
 </section>

 <div id="dialog-b" title="Auth Emp.">
 <table style=" width:98%" class="">
   <tr class="rowa">
   <td class="head cell text-right"  style="padding:10px 0px; width:30%">Emp code</td>
   <td class="cell"><input type="text" id="txtempnm" style=" width:75% " /></td>

</tr>
   <tr class="rowa">
   <td class="head cell text-right"  style="padding:10px 0px;">Password</td>
   <td class="cell"><input type="password" id="txtpass" style=" width:75% " /></td>

</tr>
 <tr class="rowa">
   <td class="head cell text-right"  style="padding:10px 0px;">ShortText</td>
   <td class="cell"><input type="text" id="txtshort" style=" width:75% " /></td>

</tr>
       </table>
</div>
 <div id="dialog-a" title="Do use old Topped Cord?">
   <span class="font-th">(คุณต้องการชนิดผ้าใบม้วนเดิม)</span>
 </div>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="TableContent" runat="server">
    <div style="clear: left; margin-top: 15px; ">
      <div class="float-left" style="margin-left: 10px">
         <% using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
            { %>
         <%: Html.AntiForgeryToken() %>
     <%--    <input type="button" value="EXIT" class="btn" style="height: 75px; width: 120px;"
            onclick="javascript:document.getElementById('logoutForm').submit()" />--%>
                <input type="button" value="EXIT" class="btnFooter shadow" style="height: 75px; width: 250px;"
            onclick="javascript:window.close();" />
         <% } %>
      </div>
           <div class="float-left" style="margin-left: 80px;">
         <input id="skip" type="button" value="SKIP"class="btnFooter shadow" style="height: 75px; width: 250px;" />
      </div>
          <div class="float-left" style="margin-left: 100px;">
         <input type="button" id="new" value="NEW / SAMPLE"class="btnFooter shadow "   style="height: 75px;
            width: 350px;" />
      </div>
      <div  class="float-right " style="margin-right:10px;">
         <input id="comuse" type="button" value="MAT-to-MAT"class="btnFooter shadow" style="height: 75px; width: 350px; display:none;" />
      </div>
  
   </div>  
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="ScriptsSection" runat="server">
    <style type="text/css">
       #pln {
      width: 250px;
      height: 60px;
      line-height: 60px;
      padding-left:10px;
    }
span {
display: inline-block;
vertical-align: middle;
    
line-height: normal;
}
 #bt {
   height: 40px;      /* increase the height */    
   margin: 20px;
   -webkit-box-shadow: 0 0 6px 4px #ccc;
   -moz-box-shadow: 0 0 6px 4px #ccc;
   box-shadow: 0 0 6px 4px #ccc;
   -moz-border-radius: 5px;
   border-radius: 5px;
    
   border: 1px solid #aaa;
   width: 100px;
}

      .actived
      {
         background-color: #20B2AA !important;
         color: White;
      }
      
      .hide
      {
         display: none;
      }
      .fontBig
      {
         font-size: 24pt;
         font-weight: bolder;
      }
    
      .btn
      {
         font-size: 18px !important;
       
      }
       
   </style>
      <% if (false)
      { %>
   <script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
   <% } %>
<script type="text/javascript">

    $(function () {

        var dialog;
        $("#dialog-b").dialog({
            width: 650,
            height: 400,
            autoOpen: false,
            open: function (event, ui) {
                $("#txtempnm").focus();
            },
            show: "blind",
            buttons: {
                "Back": function () {
                    $(this).dialog("close");
                },
                "OK": function () {
                    if ($("#txtempnm").val() == "") {
                        alert("ระบุข้อมูลไม่ครบ");
                        $("#txtempnm").focus();
                        return;
                    }
                    if ($("#txtpass").val() == "") {
                        alert("ระบุข้อมูลไม่ครบ");
                        $("#txtpass").focus();
                        return;
                    }
                    if ($("#txtshort").val() == "") {
                        alert("ระบุข้อมูลไม่ครบ");
                        $("#txtshort").focus();
                        return;
                    }

                    $.post('<%=Url.Action("Get_Author","BiasHead") %>' + '?users=' + $("#txtempnm").val() + '&pass=' + $("#txtpass").val()
                        , function (data) {
                            if (data.success == 0) {
                                alert(data.message);
                            }
                            else {
                                if (dialog == "new") {
                                    var url = '<%= Url.Action("Index","NewSample") %>' + '?empnm=' + $("#txtempnm").val() + '&sTxt=' + $("#txtshort").val() + '&refseq=' + $("#seq").text();
                                    window.location = url;
                                }
                                if (dialog == "skip") {
                                    var Surl = '<%= Url.Action("SKIP_ITEM","BiasHead") %>' + '?seq=' + $("#seq").text();
                                    Surl = Surl + '&empnm=' + $("#txtempnm").val() + '&sTxt=' + $("#txtshort").val()
                                    $.post(Surl, function (data) {
                                        if (data.success == 0) {
                                            alert(data.message);
                                        } else {
                                            window.location.href = window.location.href;
                                        }
                                    });
                                    $("#dialog-b").dialog("close");
                                }

                            } //else
                        }); //function
                }
            }
        });


        $("#dialog-a").dialog({
            width: 350,
            height: 200,
            autoOpen: false,
            open: function (event, ui) {
                $("#txtempnm").focus();
            },
            show: "blind",
            buttons: {
                "Yes": function () {
                    $(this).dialog("close");
                    $("#dialog-a").dialog("close");
                    var url = '<%= Url.Action("Old_ToppedCode") %>' + '?seq=' + $.trim($("#seq").text()) + '&biasno=' + '<%: TireBias.Models.SessionBag.Current.biasno %>';
                    window.location = url + '&oldSeq=' + seq;
                },
                "No": function () {
                    $("#dialog-a").dialog("close");
                    var url = '<%= Url.Action("Header_line_barcode") %>' + '?seq=' + $.trim($("#seq").text()) + '&biasno=' + '<%: TireBias.Models.SessionBag.Current.biasno %>';
                    window.location = url;
                }

            }


        });

        $("#skip").click(function () {
            dialog = "skip"
            $("#dialog-b").dialog("open");

        });
        // -- End dialog --//

        $("#new").removeClass("hide");
        var seq
        $("#bt").click(function () {
            if ($("tr.actived").length > 0) {

                $.post('<%= Url.Action("Get_LastFinish") %>' + '?code=' + $("#topped").text(), function (data) {
                    if (data.seq != "") {
                        seq = data.seq;
                        $("#dialog-a").dialog("open");
                    } else {
                        seq = "";
                        var url = '<%= Url.Action("Header_line_barcode") %>' + '?seq=' + $.trim($("#seq").text()) + '&biasno=' + '<%: TireBias.Models.SessionBag.Current.biasno %>' ;
                        window.location = url;
                    }

                });

            }
        });

        $("#new").click(function () {
            $("#dialog-b").dialog("open");
            dialog = "new"

        });

        //      $("#comuse").click(function () {
        //         var url = '<%= Url.Action("Index","CPD_USE") %>';
        //         window.location = url;
        //      });

    });
   </script>
</asp:Content>
